package com.wuxin.ssm.controller;


import com.github.pagehelper.PageInfo;
import com.wuxin.ssm.entity.Orderdetail;
import com.wuxin.ssm.entity.ProductType;
import com.wuxin.ssm.service.OrderdetailService;
import com.wuxin.ssm.service.ProductInfoService;
import com.wuxin.ssm.vo.OrderdetailVo;
import com.wuxin.ssm.vo.ProductInfoVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import java.util.List;

/**
 * @program: ssmwork
 * @ClassName OrderdetailController
 * @description: 订单
 * @author: 李尧坤
 * @create: 2024−12-31 09:18
 * @Version 1.0
 **/
@Controller
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private OrderdetailService orderdetailService;

    //每页显示5条属性
    public  static  final int PAGE_SIZE=5;

    /**
     *
     * @param page
     * @param model
     * @param session
     * @return
     */
    @RequestMapping("/split.action")
    public String split(Integer page,OrderdetailVo ordervo, Model model, HttpSession session){
        //声明一个p代表页码
        Integer p = 1;
        if (page != null) {
            p = page;
        }
        if (page == null) {
            page = p;
        }
        //开始分页
        PageInfo info= orderdetailService.splitPage(page,PAGE_SIZE);
        //存储一下
        model.addAttribute("ord",info);

        return "order";
    }


    @RequestMapping("/mySplict.action")
    public String mySplict(Integer page, OrderdetailVo ordervo, Model model, HttpSession session){

        //声明一个p代表页码
        Integer p = 1;

        if (page != null) {
            p=page;
        }
        if (page == null) {
            page = p;
        }

        //多条件组合查询
        PageInfo chaxun = orderdetailService.chaxun(page,PAGE_SIZE,ordervo);

        System.out.println("-------------------------------");
        System.out.println(ordervo.getOid());
        System.out.println(ordervo.getUname());
        //存储一下
        model.addAttribute("ord",chaxun);

        session.setAttribute("ordervo",ordervo);
/*        	<!--视图解析器-->
	<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
		<property name="prefix" value="/admin/"></property>
		<property name="suffix" value=".jsp"></property>

	</bean>*/

        // /admin/product.jsp

        return "order"; //逻辑视图名  redirect:/
    }
}
